package check;

import javax.swing.*;
import java.awt.*;

public class CheckBoxEditor extends DefaultCellEditor {
    protected JCheckBox checkBox;

    public CheckBoxEditor(JCheckBox checkBox) {
        super(checkBox);
        this.checkBox = checkBox;
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value,
                                                 boolean isSelected, int row, int column) {
        checkBox.setSelected((value != null && ((Boolean) value).booleanValue()));
        return checkBox;
    }

    @Override
    public Object getCellEditorValue() {
        return checkBox.isSelected();
    }
}
